#include "layer.hpp"
#include "LayerManager.hpp"

namespace wolf {
Layer::Layer(int depth_, bool visible_) :
		depth(depth_), visible(visible_) {
	if (visible_) {
		LayerManager::getInstance().addLayer(*this);
//		Engine::getInstance().addLayer(*this);
	}
}

Layer::~Layer() {
	LayerManager::getInstance().removeLayer(*this);
}

int Layer::getDepth(void) {
	return depth;
}

void Layer::setDepth(int depth_) {
//	Engine &engine = Engine::getInstance();
	LayerManager &manager = LayerManager::getInstance();
	if (visible) {
//		engine.removeLayer(*this);
		manager.removeLayer(*this);
		depth = depth_;
//		engine.addLayer(*this);
		manager.addLayer(*this);
	} else
		depth = depth_;
}
bool Layer::isVisible() const {
	return visible;
}

void Layer::setVisible(bool visible) {
	if (this->visible != visible) {
		this->visible = visible;
//		Engine &engine = Engine::getInstance();
		LayerManager &manager = LayerManager::getInstance();
		if (visible)
			manager.addLayer(*this);
//			engine.addLayer(*this);
		else
			manager.removeLayer(*this);
//			engine.removeLayer(*this);
	}
}
}
